package com.icebartech.core.utils;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import org.apache.commons.lang3.StringUtils;


public class PathUtil {
	public static String FILE_TEMP_PATH = null;
	static{
		FILE_TEMP_PATH = Thread.currentThread().getContextClassLoader().getResource("").getPath();
		if(StringUtils.isNotBlank(FILE_TEMP_PATH)){
			if("\\".equals(File.separator)){
				FILE_TEMP_PATH = FILE_TEMP_PATH.substring(1,FILE_TEMP_PATH.length());//去掉开头的"/"和末尾的"classes/"
			}else if("/".equals(File.separator)){
				FILE_TEMP_PATH = FILE_TEMP_PATH.substring(0,FILE_TEMP_PATH.length());//去掉末尾的"classes/"
			}
			try {
				FILE_TEMP_PATH = URLDecoder.decode(FILE_TEMP_PATH, "UTF-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		System.out.println(PathUtil.FILE_TEMP_PATH);
	}
}
